<?php
/**
 * @ClassName: Membersetting
 * @Description: 会员设置
 * @author: gydtrade
 * @Date: 2024-09-09 23:03
 * @Version: V1.0.0
 */

namespace app\admin\controller\paidmember;

use app\common\model;
use think\Controller;
use tpext\builder\common\Builder;

class Membersetting extends Controller
{
    protected function initialize()
    {
        parent::initialize();
    }

    public function index()
    {
        // 获取数据
        $config_data = model\SystemConfig::where('config_tab_id', 4)->find();

        // 接收并保存参数
        if (request()->isPost()) {
            $data = $this->request->param();
            $res = true;
            if ($res) {
                $this->success('修改成功', url('/admin/paidmember.membersetting/index'));
            } else {
                $this->error('修改失败', url('/admin/paidmember.membersetting/index'));
            }
        }

        $builder = Builder::getInstance('付费会员设置');
        $builder->column(1);
        $form = $builder->column(10)->form();
        $form->fill($config_data);

        $form->switchBtn('app_secret', '是否开启付费会员')->default(0)->required()->help('付费会员开关');
        $form->switchBtn('app_record_number', '付费会员价展示')->default(0)->required()->help('开启后付费会员商品将展示付费会员价');
        $form->tabEnd();

        return $builder;
    }

}